home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
- __cvsid__ = '$Id: interpreter.py 44235 2007-01-17 23:05:14Z RD $'
- __revision__ = '$Revision: 44235 $'[11:-2]
- import os
- import sys
- from code import InteractiveInterpreter
- import dispatcher
- import introspect
- import wx
-
- class Interpreter(InteractiveInterpreter):
- revision = __revision__
-
- def __init__(self, locals = None, rawin = None, stdin = sys.stdin, stdout = sys.stdout, stderr = sys.stderr, showInterpIntro = True):
- InteractiveInterpreter.__init__(self, locals = locals)
- self.stdin = stdin
- self.stdout = stdout
- self.stderr = stderr
- if rawin:
- import __builtin__
- __builtin__.raw_input = rawin
- del __builtin__
-
- if showInterpIntro:
- copyright = 'Type "help", "copyright", "credits" or "license"'
- copyright += ' for more information.'
- self.introText = 'Python %s on %s%s%s' % (sys.version, sys.platform, os.linesep, copyright)
-
-
- try:
- sys.ps1
- except AttributeError:
- sys.ps1 = '>>> '
-
-
- try:
- sys.ps2
- except AttributeError:
- sys.ps2 = '... '
-
- self.more = 0
- self.commandBuffer = []
- self.startupScript = None
-
-
- def push(self, command):
- if type(command) == unicode:
-
- try:
- command = command.encode(wx.GetDefaultPyEncoding())
- except UnicodeEncodeError:
- pass
- except:
- None<EXCEPTION MATCH>UnicodeEncodeError
-
-
- None<EXCEPTION MATCH>UnicodeEncodeError
- if not self.more:
-
- try:
- del self.commandBuffer[-1]
- except IndexError:
- pass
- except:
- None<EXCEPTION MATCH>IndexError
-
-
- None<EXCEPTION MATCH>IndexError
- if not self.more:
- self.commandBuffer.append([])
-
- self.commandBuffer[-1].append(command)
- source = '\n'.join(self.commandBuffer[-1])
- more = self.more = self.runsource(source)
- dispatcher.send(signal = 'Interpreter.push', sender = self, command = command, more = more, source = source)
- return more
-
-
- def runsource(self, source):
- stdin = sys.stdin
- stdout = sys.stdout
- stderr = sys.stderr
- sys.stdin = self.stdin
- sys.stdout = self.stdout
- sys.stderr = self.stderr
- more = InteractiveInterpreter.runsource(self, source)
- if sys.stdin == self.stdin:
- sys.stdin = stdin
-
- if sys.stdout == self.stdout:
- sys.stdout = stdout
-
- if sys.stderr == self.stderr:
- sys.stderr = stderr
-
- return more
-
-
- def getAutoCompleteKeys(self):
- return [
- ord('.')]
-
-
- def getAutoCompleteList(self, command = '', *args, **kwds):
- stdin = sys.stdin
- stdout = sys.stdout
- stderr = sys.stderr
- sys.stdin = self.stdin
- sys.stdout = self.stdout
- sys.stderr = self.stderr
- l = introspect.getAutoCompleteList(command, self.locals, *args, **kwds)
- sys.stdin = stdin
- sys.stdout = stdout
- sys.stderr = stderr
- return l
-
-
- def getCallTip(self, command = '', *args, **kwds):
- return introspect.getCallTip(command, self.locals, *args, **kwds)
-
-
-
- class InterpreterAlaCarte(Interpreter):
-
- def __init__(self, locals, rawin, stdin, stdout, stderr, ps1 = 'main prompt', ps2 = 'continuation prompt'):
- Interpreter.__init__(self, locals = locals, rawin = rawin, stdin = stdin, stdout = stdout, stderr = stderr)
- sys.ps1 = ps1
- sys.ps2 = ps2
-
-
-